package com.morningstar.system.controller.result;


import com.morningstar.common.result.Result;
import com.morningstar.system.dao.entity.SysFile;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class ArcoDesignFile {

    private static final String DONE = "done";

    /**
     * 当前上传文件的唯一标示
     */
    private Long uid;
    /**
     * 当前上传文件的状态
     */
    private String status;
    /**
     * 文件地址
     */
    private String url;
    /**
     * 文件名称
     */
    private String name;
    /**
     * 上传时返回的对象
     */
    private Result<Object> response;

    public static ArcoDesignFile success(SysFile sysFile, String urlPrefix) {
        ArcoDesignFile arcoDesignFile = new ArcoDesignFile();
        arcoDesignFile.setUid(sysFile.getFileId());
        arcoDesignFile.setStatus(DONE);
        arcoDesignFile.setName(sysFile.getFileName());
        arcoDesignFile.setUrl(urlPrefix + sysFile.getFilePath());

        FileUploadResult fileUploadResult = new FileUploadResult();
        fileUploadResult.setFileId(sysFile.getFileId());
        fileUploadResult.setPreviewUrl(urlPrefix + sysFile.getFilePath());

        arcoDesignFile.setResponse(Result.successData(fileUploadResult));
        return arcoDesignFile;
    }
}
